package com.atguigu01._this.exer1;

/**
 * ClassName: PersonTest
 * Description:
 *
 * @Author liu
 * @Create 2024/10/25 10:17
 * @Version 1.0
 */
public class Girl {
    private String name;
    private int age;

    public void setName(String i){
        this.name = i;
    }
    public String getName(){
        return name;
    }

    public Girl() {
    }

    public Girl(String name,int age) {
        this.age = age;
        this.name = name;
    }

    public void marry(boy boy){
        System.out.println("我想嫁给"+boy.getName());
    }

    /**
     * 比较两个girl对象的大小
     * @param girl
     * @return 正数 当前对象大；负数 当前对象小（形参girl小）；0为相等
     */
    public int compare(Girl girl){
        if(this.age > girl.age){
            return 1;
        } else if (this.age < girl.age) {
            return -1;
        }else {
            return 0;
        }
    }
}